import QtQuick 2.0
import QtQuick.Layouts 1.12
Rectangle {
    id: root

    function refresh(){
        console.log("刷新列表" + (stepNum - 1))
        textTemperature.text = gProgramStep[stepNum-1]["Temperature"]
        textExecutionTime.text = gProgramStep[stepNum-1]["ExecutionTime"]
        textCycleNumber.text = gProgramStep[stepNum-1]["CycleNumber"]
        textCycleNum.text = gProgramStep[stepNum-1]["CycleNum"]
        textRate.text = gProgramStep[stepNum-1]["Rate"]
        textIsCollect.text = gProgramStep[stepNum-1]["IsCollect"]
    }

    property int stepNum: 0

    MouseArea{
        anchors.fill: parent
        hoverEnabled: true
        onEntered: root.color = "#F2F9FF"
        onExited: root.color = "white"
    }

    height: 50
    width: parent.width

    RowLayout{
        anchors.fill: parent
        spacing: 0
        Item{
            height: parent.height
            width: 80

            TextInput{
                text: stepNum
                anchors.fill: parent
                verticalAlignment: TextInput.AlignVCenter
                anchors.margins: 5
            }
        }Item{
            height: parent.height
            width: 80

            TextInput{
                id: textTemperature
                anchors.fill: parent
                verticalAlignment: TextInput.AlignVCenter
                anchors.margins: 5
                onTextChanged: {
                    gProgramStep[stepNum-1]["Temperature"] = text
                }
            }
        }Item{
            height: parent.height
            width: 80

            TextInput{
                id: textRate
                anchors.fill: parent
                verticalAlignment: TextInput.AlignVCenter
                anchors.margins: 5
                onTextChanged: {
                    gProgramStep[stepNum-1]["Rate"] = text
                }
            }
        }Item{
            height: parent.height
            width: 80

            TextInput{
                id: textExecutionTime
                anchors.fill: parent
                verticalAlignment: TextInput.AlignVCenter
                anchors.margins: 5
                onTextChanged: {
                    gProgramStep[stepNum-1]["ExecutionTime"] = text
                }
            }
        }Item{
            height: parent.height
            width: 80

            TextInput{
                id: textIsCollect
                anchors.fill: parent
                verticalAlignment: TextInput.AlignVCenter
                anchors.margins: 5
                onTextChanged: {
                    gProgramStep[stepNum-1]["IsCollect"] = text
                }
            }
        }Item{
            height: parent.height
            width: 80

            TextInput{
                id: textCycleNumber
                anchors.fill: parent
                verticalAlignment: TextInput.AlignVCenter
                anchors.margins: 5
                onTextChanged: {
                    gProgramStep[stepNum-1]["CycleNumber"] = text
                }
            }
        }Item{
            height: parent.height
            width: 80
            TextInput{
                id: textCycleNum
                anchors.fill: parent
                verticalAlignment: TextInput.AlignVCenter
                anchors.margins: 5
                onTextChanged: {
                    gProgramStep[stepNum-1]["CycleNum"] = text
                }
            }
        }Item{
            height: parent.height
            width: parent.width / 8

            Item{
                width: 50
                height: parent.height
                x: 0
                Text {
                    text: qsTr("添加")
                    color: "#1677FF"
                    anchors.centerIn: parent
                }
                MouseArea{
                    anchors.fill: parent
                    cursorShape: Qt.PointingHandCursor
                    onReleased: {
                        addStep(stepNum)
                    }
                }
            }Item{
                width: 50
                height: parent.height
                x: 50
                Text {
                    text: qsTr("删除")
                    color: "#1677FF"
                    anchors.centerIn: parent
                }
                MouseArea{
                    anchors.fill: parent
                    cursorShape: Qt.PointingHandCursor
                    onReleased: {
                        delStep(stepNum)
                    }
                }
            }
        }


    }



}
